﻿using AutoMapper;
using System.Data;
using VisionCloud.Core.Model.Ms;
using VisionCloud.Core.Model.Schedule;
using VisionCloud.Core.Model.Sys;
using VisionCloud.Domain.DtoModel.Ms;
using VisionCloud.Domain.DtoModel.Schedule.ProjectInfo;
using VisionCloud.Domain.DtoModel.Schedule.RobotInfo;
using VisionCloud.Domain.DtoModel.Schedule.WorkOrder;
using VisionCloud.Domain.DtoModel.Sys;
using VisionCloud.Utility.Extensions;

namespace VisionSurface.Web.Config
{
    public class AutoMapperConfigs : Profile
    {
        /// <summary>
        /// 构造
        /// </summary>
        public AutoMapperConfigs()
        {
            CreateMap<IDataReader, ReportDto>();
            CreateMap<SysDevice, SysDeviceDto>()
                .ForMember(x => x.Mac, y => y.MapFrom(x => x.DeviceMac));
            CreateMap<SysDevice, RobotInfoDto>()
                .ForMember(x => x.Id, y => y.MapFrom(x => x.DeviceGuid))
                .ForMember(x => x.RobotNumber, y => y.MapFrom(x => x.DeviceNumber))
                .ForMember(x => x.CreateTime, y => y.MapFrom(x => x.CreatedDate.ToStanderTimeString()))
                .ForMember(x => x.Owner, y => y.MapFrom(x => x.DeviceUserName))
                .ForMember(x => x.Status, y => y.MapFrom(x => x.AvailableStatus));
            CreateMap<MsAlgorithmParamTemplate, MsAlgoTempDto>();

            CreateMap<MsProject, ScheduleProjectInfoDto>()
                .ForMember(x => x.CreateTime, y => y.MapFrom(x => x.CreatedDate.ToStanderTimeString()));
            CreateMap<MsProject, ScheduleProjectDetailDto>()
                .ForMember(x => x.Id, y => y.MapFrom(x => x.ProjectId))
                .ForMember(x => x.ProjectName, y => y.MapFrom(x => x.Name));
            CreateMap<RsWorkOrderAddDto, RsWorkOrder>();
            CreateMap<RsWorkOrder, WorkOrderDetailDto>()
                .ForMember(x => x.CreateTime, y => y.MapFrom(x => x.CreatedDate.ToStanderTimeString()))
                .ForMember(x => x.RobotId, y => y.MapFrom(x => x.DeviceId))
                .ForMember(x => x.RobotName, y => y.MapFrom(x => x.ProjectName + "测量机器人"));
        }
    }
}
